#include <stdio.h>
#include "hrd_displayer.h"
#include "hrd_boundary_displayer.h"
#include "hrd_table.h"

#define empty_space_character " "

#define left_of_top_boundary    "┌"
#define mid_of_top_boundary     "┬"
#define right_of_top_boundary   "┐"

#define left_of_split_line  "├"
#define mid_of_split_line   "┼"
#define right_of_split_line "┤"

#define left_of_bottom_boundary     "└"
#define mid_of_bottom_boundary      "┴"
#define right_of_bottom_boundary    "┘"
#define line "─"


void HrdBoundaryDisplayer_DisplayerTopBoundary(int8_t top_row[8])
{
    uint8_t i;

    printf(left_of_top_boundary);
    for (i = 1; i < 7; i++) {
        if (top_row[i] == BOUNDARY_CODE) {
            printf(line mid_of_top_boundary);
        } else {
            printf("%s" empty_space_character, top_row[i - 1] == BOUNDARY_CODE ? line : empty_space_character);
        }
    }
    printf(line right_of_top_boundary "\n");
}


void HrdBoundaryDisplayer_DisplayerBottomBoundary(int8_t bottom_row[8])
{
    uint8_t i;

    printf(left_of_bottom_boundary);
    for (i = 1; i < 7; i++) {
        if (bottom_row[i] == BOUNDARY_CODE) {
            printf(line mid_of_bottom_boundary);
        } else {
            printf("%s" empty_space_character, bottom_row[i - 1] == BOUNDARY_CODE ? line : empty_space_character);
        }
    }
    printf(line right_of_bottom_boundary "\n");
}


void HrdBoundaryDisplayer_DisplayerLeftBoundary(int8_t table_code)
{
    if (table_code == BOUNDARY_CODE) {
        printf(left_of_split_line);
    } else {
        printf(empty_space_character);
    }
}


void HrdBoundaryDisplayer_DisplayerRightBoundary(int8_t table_code)
{
    if (table_code == BOUNDARY_CODE) {
        printf(" " right_of_split_line "\n");
    } else {
        printf(" " empty_space_character "\n");
    }
}